package com.mvetc.dao.impl;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

import com.mvetc.dao.ManagerDao;
import com.mvetc.entity.Manager;
import com.mvetc.util.DBUtil;

public class ManagerDaoImpl implements ManagerDao {

	@Override
	public Map<String, String> findManagerByIdAndPassword(String managerId, String managerPassword) {
		Map<String, String> map = null;
		ResultSet doQuery = DBUtil.doQuery("select manager_id,manager_password from manager_info where manager_id = ? and manager_password = ?", managerId,managerPassword);
		try {
			if (doQuery.next()==true) {
				map = new HashMap<>();
				map.put("managerId", managerId);
				map.put("managerPassword", managerPassword);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return map;
	}
	
	@Override
	public int updatePasswordById(Manager manager) {
		int doUpdate = DBUtil.doUpdate("update manager_info set manager_password = ? where manager_id = ?", manager.getManagerPassword(),manager.getManagerId());
		return doUpdate;
	}

}
